$(function(){
	//律师用户中心免费咨询请求
	var length_url =200;
	var page = 1;
	questionSwitch()
	function questionSwitch() {
		var oDiv = $("#lv-tab-box");
		var oLi = $("#lv-tab-box .tabList li")
		var aCon = $("#lv-tab-box .tabCon ul")
		var timer = null;
		for (var i = 0; i < oLi.length; i++) {
		    oLi[i].index = i;
		    oLi[i].onclick = function() {
		    	$(".tabCon .cur li").remove();
		    	$(".redtitle").remove();
		    	show(this.index);
		   }
		}
		function show(a) {
			index = a;
			var alpha = 0;
			for (var j = 0; j < oLi.length; j++) {
			    oLi[j].className = "";
			    aCon[j].className = "";
			    aCon[j].style.opacity = 0;
			    aCon[j].style.filter = "alpha(opacity=0)";
			}
			oLi[index].className = "cur";
			aCon[index].className = "cur";
			$(".item_pager .loadMore").css("display","none");
			$(".loadmore").attr("data-href",1);
		    switch(index){
		    	case 0:
		        	question_new(page);
		        break;
		        case 1:
		        	question_replied(page);
		        break;
		        case 2:
		        	question_toEvaluate(page);
		        break;
		        case 3:
		        	question_complete(page);
		        break;
		        case 4:
		        	question_cancelled(page);
		        break;
		    }
		    clearInterval(timer);
		    timer = setInterval(function() {
		    	alpha += 2;
		        alpha > 100 && (alpha = 100);
		        aCon[index].style.opacity = alpha / 100;
		        aCon[index].style.filter = "alpha(opacity=" + alpha + ")";
		        alpha == 100 && clearInterval(timer);
		    },5)
		}
	};
	function addTo(i) {
		var oLi = $("#lv-tab-box .tabList li")
		$(".tabCon .cur li").remove();
    	$(".redtitle").remove();
    	$("#lv-tab-box .tabList li").removeClass("cur").eq(i).addClass("cur");
    	if (i==0) {
    		question_new(page);
    	}else if(i==1){
    		question_replied(page);
    	}else if(i==2){
    		question_toEvaluate(page);
    	}else if(i==3){
    		question_complete(page);
    	}else if(i==4){
    		question_cancelled(page);
    	}
	};

	status_url(page);
	function status_url(page){
		$("#lv-tab-box .tabList a").eq(0).attr("href",jumpUrl+"/center/lawyer/question_order/"+question_type+"/new")
		$("#lv-tab-box .tabList a").eq(1).attr("href",jumpUrl+"/center/lawyer/question_order/"+question_type+"/replied")
		$("#lv-tab-box .tabList a").eq(2).attr("href",jumpUrl+"/center/lawyer/question_order/"+question_type+"/wait_for_evaluation")
		$("#lv-tab-box .tabList a").eq(3).attr("href",jumpUrl+"/center/lawyer/question_order/"+question_type+"/complete")
		$("#lv-tab-box .tabList a").eq(4).attr("href",jumpUrl+"/center/lawyer/question_order/"+question_type+"/cancelled")
		if (status_status == "new") {
    		addTo(0)
    		return false;
    	}else if(status_status == "replied"){
    		addTo(1)
    		return false;
    	}else if(status_status == "wait_for_evaluation"){
    		addTo(2)
    		return false;
    	}else if(status_status == "complete"){
    		addTo(3)
    		return false;
    	}else if(status_status == "cancelled"){
    		addTo(4)
    		return false;
    	}else if(status_status == "view"){
    		question_view(page);
    		return false;
    	}else{
    		window.location.href = jumpUrl+"/center/lawyer/question_order/"+question_type+"/new"
    	}
	}
	//列表背景颜色
	function background_color(){
		for(var j=0; j<length_url; j++){
          if (j%2 == 0) {
          $(".tabCon .cur li").eq(j).css("background-color","#f0f0f0");
            }
        }
    };
    
	// 待受理
	function question_new (page) {
		var loading = '<li><div class="loading">加载中...</div></li>'; 
		$(".tabCon .cur").append(loading);
		url = jumpUrl+"/center/question/list?type="+question_type+"&status=new&page="+page+"&rows_per_page=10";
		$.get(url,{},function(e){
		}, 'json').error(function(data){
			var obj = $.parseJSON(data.responseText);
	        $.each(obj.error_messages, function(i, item){
		        layer.msg(item[0]);
		        stch = false;
	        });
		}).success(function(data){
			$(".loading").parent().remove();
			var obj = data.data;
			console.info(obj)
			var str = '';
			if(obj.length ==0 ){
				str = '<div class="redtitle">暂时没有数据<div>';
			}
			if(obj.length>9){
				$(".item_pager .loadMore").css("display","block");
				$(".item_pager .loadMore").attr("data-id","0");
			}
			for(var i=0; i<obj.length; i++){
					if (question_type == "question") {
						str+='<li class="new-box">';
							str+='<span class="new-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
							str+='<span class="new-category">'+obj[i].post_category+'</span>'
							str+='<span><a href="##" data-href="'+obj[i].id+'" class="button-bg button01 js_to_take">抢单</a></span>'
						str+='</li>';
					}else if (question_type == "pay_company") {
						str+='<li class="new-box">';
							str+='<span class="new-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
							str+='<span class="new-category">&nbsp;</span>'
							str+='<span><a href="##" data-href="'+obj[i].id+'" class="button-bg button01 js_to_take">抢单</a></span>'
						str+='</li>';
					}else{
						str+='<li class="new-box2">';
							str+='<span class="new-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
							str+='<span class="new-category">'+obj[i].post_category+'</span>'
							str+='<span><a href="##" data-href="'+obj[i].id+'" class="button-bg button01 js_accept">接受</a><br><a href="##" data-href="'+obj[i].id+'" class="button-bg button02 js_refuse">拒绝</a></span>'
						str+='</li>';
					
					}
				
			}
			$('.tabCon .cur').append(str);
			background_color();
		});
	}
	// 待确认
	function question_replied(page) {
		var loading = '<li><div class="loading">加载中...</div></li>'; 
		$(".tabCon .cur").append(loading);
		url = jumpUrl+"/center/question/list?type="+question_type+"&status=replied&page="+page+"&rows_per_page=10"
		$.get(url,{},function(e){
		}, 'json').error(function(data){
			var obj = $.parseJSON(data.responseText);
	        $.each(obj.error_messages, function(i, item){
		        layer.msg(item[0]);
		        stch = false;
	        });
		}).success(function(data){
			$(".loading").parent().remove();
			var obj = data.data;
			console.info(obj)
			var str = '';
			if(obj.length ==0 ){
				str = '<div class="redtitle">暂时没有数据<div>';
			}
			if(obj.length>9){
				$(".item_pager .loadMore").css("display","block");
				$(".item_pager .loadMore").attr("data-id","1");
			}
			for(var i=0; i<obj.length; i++){
				str+='<li class="replied-box">';
					str+='<span class="replied-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
					if (question_type == "pay_company") {
						str+='<span class="replied-category">&nbsp;</span>'
					}else{
					str+='<span class="replied-category">'+obj[i].post_category+'</span>'
					}
					str+='<span>'
						str+='<a href="javascript:void(0)" data-id="'+obj[i].id+'" class="button-bg button01 to_ask">联系客户</a>'
					str+='</span>'
				str+='</li>';
				
			}
			$('.tabCon .cur').append(str);
			background_color();
		});
	}
	// 待评价
	function question_toEvaluate (page) {
		var loading = '<li><div class="loading">加载中...</div></li>'; 
		$(".tabCon .cur").append(loading);
		url = jumpUrl+"/center/question/list?type="+question_type+"&status=wait_for_evaluation&page="+page+"&rows_per_page=10"
		$.get(url,{},function(e){
		}, 'json').error(function(data){
			var obj = $.parseJSON(data.responseText);
	        $.each(obj.error_messages, function(i, item){
		        layer.msg(item[0]);
		        stch = false;
	        });
		}).success(function(data){
			$(".loading").parent().remove();
			var obj = data.data;
			console.info(obj)
			var str = '';
			if(obj.length ==0 ){
				str = '<div class="redtitle">暂时没有数据<div>';
			}
			if(obj.length>9){
				$(".item_pager .loadMore").css("display","block");
				$(".item_pager .loadMore").attr("data-id","2");
			}
			for(var i=0; i<obj.length; i++){
				str+='<li class="evaluate-box">';
					str+='<span class="evaluate-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
					str+='<span class="evaluate-category" style="width:140px;height:40px;"></span>'
					if (question_type == "pay_company") {
						str+='<span>&nbsp;</span>'
					}else{
						str+='<span>'+obj[i].post_category+'</span>'
					}
				str+='</li>';
			}
			$('.tabCon .cur').append(str);
			background_color();
		});
	}
	// 已完成
	function question_complete (page) {
		var loading = '<li><div class="loading">加载中...</div></li>'; 
		$(".tabCon .cur").append(loading);
		url = jumpUrl+"/center/question/list?type="+question_type+"&status=complete&page="+page+"&rows_per_page=10"
		$.get(url,{},function(e){
		}, 'json').error(function(data){
			var obj = $.parseJSON(data.responseText);
	        $.each(obj.error_messages, function(i, item){
		        layer.msg(item[0]);
		        stch = false;
	        });
		}).success(function(data){
			$(".loading").parent().remove();
			var obj = data.data;
			var str = '';
			if(obj.length ==0 ){
				str = '<div class="redtitle">暂时没有数据<div>';
			}
			if(obj.length>9){
				$(".item_pager .loadMore").css("display","block");
				$(".item_pager .loadMore").attr("data-id","3");
			}
			for(var i=0; i<obj.length; i++){
				str+='<li class="complete-box">';
					str+='<span class="complete-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
					if (question_type == "pay_company") {
						str+='<span class="complete-category">&nbsp;</span>'
					}else{
						str+='<span class="complete-category">'+obj[i].post_category+'</span>'
					}
					str+='<span>'
						str+='<a href="##" data-id="'+obj[i].id+'" class="button-bg button01 delete-question">删除</a>'
					str+='</span>'
				str+='</li>';
			}
			$('.tabCon .cur').append(str);
			background_color();
		});
	};

	// 已删除
	function question_cancelled(page) {
		var loading = '<li><div class="loading">加载中...</div></li>'; 
		$(".tabCon .cur").append(loading);
		url = jumpUrl+"/center/question/list?type="+question_type+"&status=cancelled&page="+page+"&rows_per_page=10"
		$.get(url,{},function(e){
		}, 'json').error(function(data){
			var obj = $.parseJSON(data.responseText);
	        $.each(obj.error_messages, function(i, item){
		        layer.msg(item[0]);
		        stch = false;
	        });
		}).success(function(data){
			$(".loading").parent().remove();
			var obj = data.data;
			console.info(obj)
			var str = '';
			if(obj.length ==0 ){
				str = '<div class="redtitle">暂时没有数据<div>';
			}
			if(obj.length>9){
				$(".item_pager .loadMore").css("display","block");
				$(".item_pager .loadMore").attr("data-id","4");
			}
			for(var i=0; i<obj.length; i++){
				str+='<li class="cancelled-box">';
					str+='<span class="cancelled-title"><a class="view-href" data-id="'+obj[i].id+'" href="'+jumpUrl+'/center/lawyer/question_order/'+obj[i].id+'/view">'+obj[i].title+'</a></span>'
					if (question_type == "pay_company") {
						str+='<span class="cancelled-category"></span>'
					}else{
						str+='<span class="cancelled-category">'+obj[i].post_category+'</span>'
					}
					str+='<span><a href="##" data-id="'+obj[i].id+'" class="button-bg button01 delete-question">删除</a></span>'
				str+='</li>';
			}
			$('.tabCon .cur').append(str);
			background_color();
		});
	};


	//详情页
	// $(document).on( "click", ".view-href", function(e) {
	// 	$(".tabCon .cur li").remove();
	// 	var loading = '<li><div class="loading">加载中...</div></li>'; 
	// 	$(".tabCon .cur").append(loading);
	// 	var user_id = $(this).attr("data-id");
	// 	var url = jumpUrl+"/center/question/"+user_id+"/view"
	//     $.get(url,function(data){
	        
	//       },'json').error(function(data) {
	//           // var obj = $.parseJSON(data.responseText);
	//           // $.each(obj.error_messages, function(i, item){
	//           // });
	//       }).success(function(data) {
	//       	$(".loading").parent().remove();
	//       	var obj = data.data
	//       	var attachments = obj.attachments
	//       	var status = obj.status
	//       	console.info(obj)

	//       	var str = ''
	//       		if (question_type == "pay_company") {
	//       			str+='<div class="view-box">'
	//       				str+='<li><span class="span1">订单编号：</span><span class="span2">'+obj.order_no+'</span></li>'
	// 					str+='<li><span class="span1">创建时间：</span><span class="span2">'+obj.created_at+'</span></li>'
	// 					str+='<li><span class="span1">订单名称：</span><span class="span2">'+obj.title+'</span></li>'
	// 					str+='<li><span class="span1">邮箱地址：</span><span class="span2">'+obj.email+'</span></li>'
	// 					str+='<li><span class="span1">企业信息：</span><span class="span2">'+obj.company_name+'</span></li>'
	// 					str+='<li><span class="span1">企业地址：</span><span class="span2">'+obj.province + obj.city + obj.district+'</span></li>'
	// 					str+='<li><span class="span1">备注信息：</span><span class="span2">'+obj.memo+'</span></li>'
	// 					str+='<li>'
	// 						str+='<p style="margin:40px 0 0 80px;">'
	// 						if (status == "new") {
	// 							str+='<a href="##" data-href="'+obj.id+'" class="button-bg js_cancel">取消</a>'
	// 						}else if(status == "replied"){
	// 							str+='<a href="##" data-id="'+obj.id+'" class="button-bg js_to_complete">确认</a>'
	// 							str+='<a href="javascript:void(0)" data-id="'+obj.id+'" class="button-bg to_ask">联系律师</a>'
	// 						}else if (status == "wait_for_evaluation") {
	// 							str+='<a href="##" data-href="'+obj.id+'" class="button-bg comment">评价</a>'
	// 						}else if (status == "complete") {
	// 							str+='<a href="##" class="button-bg">删除</a>'
	// 						}else if (status == "cancelled") {
	// 							str+='<a href="##" data-id="'+obj.id+'" class="button-bg delete-question">删除</a>'
	// 						}
	// 						str+='</p>'
	// 					str+='</li>'
	// 				str+='</div>'
	// 				$('.tabCon .cur').append(str);
	//       		}else{
	// 	            str+='<div class="view-box">'
	// 					str+='<li><span class="span1">创建时间：</span><span class="span2">'+obj.created_at+'</span></li>'
	// 					str+='<li><span class="span1">咨询标题：</span><span class="span2">'+obj.title+'</span></li>'
	// 					str+='<li><span class="span1">咨询详情：</span><span class="span2">'+obj.content+'</span></li>'
	// 					if (attachments.length !== 0) {
	// 					str+='<li><span class="span1">咨询附件：</span><span class="span2"><p>'
	// 						for (var i = 0; i < attachments.length; i++) {
	// 							str+='<a href="'+jumpUrl+'/file/download/?path='+attachments[i].src+'" target="_blank"><img src="'+attachments[i].url+'" width="100" height="100" style="margin-right: 20px;"></a>'
	// 						}
	// 					}
	// 					str+='</span></li>'	
	// 					str+='<li>'
	// 						str+='<p style="margin:40px 0 0 80px;">'
	// 						if (status == "new") {
	// 							if (question_type == "question"||question_type == "pay_company") {
	// 							str+='<a href="##" data-href="'+obj.id+'" class="button-bg js_to_take">抢单</a>'
	// 							}else{
	// 								str+='<a href="##" data-href="'+obj.id+'" class="button-bg button01 js_accept">接受</a><a href="##" data-href="'+obj.id+'" class="button-bg button02 js_refuse">拒绝</a>'
	// 							}
	// 						}else if(status == "replied"){
	// 							str+='<a href="javascript:void(0)" data-id="'+obj.id+'" class="button-bg to_ask">联系用户</a>'
	// 						}else if (status == "wait_for_evaluation") {
	// 							str+='<span>等待用户评价</span>'
	// 						}else if (status == "complete") {
	// 							str+='<a href="##" data-id="'+obj.id+'" class="button-bg button01 delete-question">删除</a>'
	// 						}
	// 						str+='</p>'
	// 					str+='</li>'
	// 				str+='</div>'
	// 				$('.tabCon .cur').append(str);
	// 			}
	//       })
	//       stopDefault(e);
	// });

	//详情页
	function question_view(e){
		var loading = '<li><div class="loading">加载中...</div></li>'; 
		$(".tabCon .cur").append(loading);
		var user_id = question_view_id;
		var url = jumpUrl+"/center/question/"+user_id+"/view"
	    $.get(url,function(data){
	        
	      },'json').error(function(data) {
	          // var obj = $.parseJSON(data.responseText);
	          // $.each(obj.error_messages, function(i, item){
	          // });
	      }).success(function(data) {
	      	$(".loading").parent().remove();
	      	var obj = data.data

	      	$(".fore1_nav").addClass("curr01");
	      	$(".fore1_nav a").removeClass("curr01");
	      	$("#lv-tab-box .tabList a li").removeClass("cur")
	      	if (obj.type== "question") {
	      		$(".fore1_nav a").eq(0).addClass("curr01");
	      		$("#lv-tab-box .tabList a").eq(4).remove();
	      	}else if (obj.type== "pay_text") {
	      		$(".fore1_nav a").eq(1).addClass("curr01");
	      	}else if (obj.type== "pay_phone") {
	      		$(".fore1_nav a").eq(2).addClass("curr01");
	      	}else if (obj.type== "pay_company") {
	      		$(".fore1_nav a").eq(3).addClass("curr01");
	      		$("#lv-tab-box.tabList a").eq(4).remove();
	      	}
	      	if (obj.status == "new") {
	    		$("#lv-tab-box .tabList a li").eq(0).addClass("cur")
	    	}else if(obj.status == "replied"){
	    		$("#lv-tab-box .tabList a li").eq(1).addClass("cur")
	    	}else if(obj.status == "wait_for_evaluation"){
	    		$("#lv-tab-box.tabList a li").eq(2).addClass("cur")
	    	}else if(obj.status == "complete"){
	    		$("#lv-tab-box .tabList a li").eq(3).addClass("cur")
	    	}else if(obj.status == "cancelled"){
	    		$("#lv-tab-box .tabList a li").eq(4).addClass("cur")
	    	}
	      	$("#lv-tab-box .tabList a").eq(0).attr("href",jumpUrl+"/center/lawyer/question_order/"+obj.type+"/new")
			$("#lv-tab-box .tabList a").eq(1).attr("href",jumpUrl+"/center/lawyer/question_order/"+obj.type+"/replied")
			$("#lv-tab-box .tabList a").eq(2).attr("href",jumpUrl+"/center/lawyer/question_order/"+obj.type+"/wait_for_evaluation")
			$("#lv-tab-box .tabList a").eq(3).attr("href",jumpUrl+"/center/lawyer/question_order/"+obj.type+"/complete")
			$("#lv-tab-box .tabList a").eq(4).attr("href",jumpUrl+"/center/lawyer/question_order/"+obj.type+"/cancelled")

	      	var attachments = obj.attachments
	      	var status = obj.status
	      	console.info(obj)
	      	var str = ''
	      		if (obj.type == "pay_company") {
	      			str+='<div class="view-box">'
	      				str+='<li><span class="span1">订单编号：</span><span class="span2">'+obj.order_no+'</span></li>'
						str+='<li><span class="span1">创建时间：</span><span class="span2">'+obj.created_at+'</span></li>'
						str+='<li><span class="span1">订单名称：</span><span class="span2">'+obj.title+'</span></li>'
						str+='<li><span class="span1">邮箱地址：</span><span class="span2">'+obj.email+'</span></li>'
						str+='<li><span class="span1">企业信息：</span><span class="span2">'+obj.company_name+'</span></li>'
						str+='<li><span class="span1">企业地址：</span><span class="span2">'+obj.province + obj.city + obj.district+'</span></li>'
						str+='<li><span class="span1">备注信息：</span><span class="span2">'+obj.memo+'</span></li>'
						str+='<li>'
							str+='<p style="margin:40px 0 0 80px;">'
							if (status == "new") {
								if (question_type == "question"||question_type == "pay_company") {
								str+='<a href="##" data-href="'+obj.id+'" class="button-bg js_to_take">抢单</a>'
								}else{
									str+='<a href="##" data-href="'+obj.id+'" class="button-bg button01 js_accept">接受</a><a href="##" data-href="'+obj.id+'" class="button-bg button02 js_refuse">拒绝</a>'
								}
							}else if(status == "replied"){
								str+='<a href="javascript:void(0)" data-id="'+obj.id+'" class="button-bg to_ask">联系用户</a>'
							}else if (status == "wait_for_evaluation") {
								str+='<span>等待用户评价</span>'
							}else if (status == "complete") {
								str+='<a href="##" data-id="'+obj.id+'" class="button-bg button01 delete-question">删除</a>'
							}else if (status == "cancelled") {
								str+='<a href="##" data-id="'+obj.id+'" class="button-bg delete-question">删除</a>'
							}
							str+='</p>'
						str+='</li>'
					str+='</div>'
					$('.tabCon .cur').append(str);
	      		}else{
		            str+='<div class="view-box">'
						str+='<li><span class="span1">创建时间：</span><span class="span2">'+obj.created_at+'</span></li>'
						str+='<li><span class="span1">咨询标题：</span><span class="span2">'+obj.title+'</span></li>'
						str+='<li><span class="span1">咨询详情：</span><span class="span2">'+obj.content+'</span></li>'
						if (attachments.length !== 0) {
						str+='<li><span class="span1">咨询附件：</span><span class="span2"><p>'
							for (var i = 0; i < attachments.length; i++) {
								str+='<a href="'+jumpUrl+'/file/download/?path='+attachments[i].src+'" target="_blank"><img src="'+attachments[i].url+'" width="100" height="100" style="margin-right: 20px;"></a>'
							}
						}
						str+='</span></li>'	
						str+='<li>'
							str+='<p style="margin:40px 0 0 80px;">'
							if (status == "new") {
								if (question_type == "question"||question_type == "pay_company") {
								str+='<a href="##" data-href="'+obj.id+'" class="button-bg js_to_take">抢单</a>'
								}else{
									str+='<a href="##" data-href="'+obj.id+'" class="button-bg button01 js_accept">接受</a><a href="##" data-href="'+obj.id+'" class="button-bg button02 js_refuse">拒绝</a>'
								}
							}else if(status == "replied"){
								str+='<a href="javascript:void(0)" data-id="'+obj.id+'" class="button-bg to_ask">联系用户</a>'
							}else if (status == "wait_for_evaluation") {
								str+='<span>等待用户评价</span>'
							}else if (status == "complete") {
								str+='<a href="##" data-id="'+obj.id+'" class="button-bg button01 delete-question">删除</a>'
							}
							str+='</p>'
						str+='</li>'
					str+='</div>'
					$('.tabCon .cur').append(str);
				}
	      })
	      stopDefault(e);
	}

	//取消
	$(document).on( "click", ".js_cancel", function(e) {
		var loading = layer.msg('操作进行中...', {icon: 16});
		var id = $(this).attr("data-href");
		var url = jumpUrl+"/center/question/"+id+"/cancel"
	    $.post(url,{},function(data){
	        
	      },'json').error(function(data) {
	          // var obj = $.parseJSON(data.responseText);
	          // layer.msg(obj.error_messages);
	      }).success(function(data) {
	          layer.msg("取消成功");
	          window.location.href=skipUrl;
	      });
	      stopDefault(e);
	});

	//删除
	$(document).on( "click", ".delete-question", function(e) {
		var loading = layer.msg('操作进行中...', {icon: 16});
		var user_id = $(this).attr("data-id");
		var url = jumpUrl+"/center/question/"+user_id+"/remove"
	    $.post(url,{},function(data){
	        
	      },'json').error(function(data) {
	          // var obj = $.parseJSON(data.responseText);
	          // layer.msg(obj.error_messages);
	      }).success(function(data) {
	          layer.msg(data.data);
	      });
	      stopDefault(e); 
	});

	//抢单
	$(document).on( "click", ".js_to_take", function(e) { 
		var loading = layer.msg('操作进行中...', {icon: 16});
		var user_id = $(this).attr("data-href");
		var url = jumpUrl+"/center/question/"+user_id+"/take"
	    $.post(url,{},function(data){
	        
	      },'json').error(function(data) {
	          // var obj = $.parseJSON(data.responseText);
	          // layer.msg(obj.error_messages);
	      }).success(function(data) {
	          layer.msg(data.data);
	          addTo(1);
	      });
	      stopDefault(e);
	});
	//接受
	$(document).on( "click", ".js_accept", function(e) { 
		var loading = layer.msg('操作进行中...', {icon: 16});
		var user_id = $(this).attr("data-href");
		var url = jumpUrl+"/center/question/"+user_id+"/accept"
	    $.post(url,{},function(data){
	        
	      },'json').error(function(data) {
	          // var obj = $.parseJSON(data.responseText);
	          // layer.msg(obj.error_messages);
	      }).success(function(data) {
	          layer.msg(data.data);
	          addTo(1);
	      });
	      stopDefault(e);
	});
	//拒绝
	$(document).on( "click", ".js_refuse", function(e) { 
		var loading = layer.msg('操作进行中...', {icon: 16});
		var user_id = $(this).attr("data-href");
		var url = jumpUrl+"/center/question/"+user_id+"/refuse"
	    $.post(url,{},function(data){
	        
	      },'json').error(function(data) {
	          // var obj = $.parseJSON(data.responseText);
	          // layer.msg(obj.error_messages);
	      }).success(function(data) {
	          layer.msg(data.data);
	          addTo(0);
	      });
	      stopDefault(e);
	});

	//联系律师
	$(document).on( "click", ".to_ask", function(e) {
		 var iTop = (window.screen.availHeight-600)/2; //获得窗口的垂直位置;
		 var iLeft = (window.screen.availWidth-715)/2; //获得窗口的水平位置;
		 id = $(this).attr("data-id");
		 chatUrl = jumpUrl+'/center/question/'+id+'/ask';
		 window.open (chatUrl, "", "height=600, width=715, top="+iTop+", left="+iLeft+", toolbar =no, menubar=no, scrollbars=no, resizable=no, location=yes, status=no")

	});
	$(document).on( "click", ".view-href", function(e) {
		$(".item_pager .loadMore").css("display","none");
	});
	  //滚动条拉到底部的时候去获取新的数据
	$(document).on("click",".loadMore",function(e){
		$(".item_pager .loadMore").css("display","none");
		var scroll_type = parseInt($(".loadmore").attr("data-id"));
	    var cuA = parseInt($(".loadmore").attr("data-href"));
	    $(".loadmore").attr("data-href",cuA+1);
	    var page = cuA+1;
	    if (scroll_type==0) {
    		question_new(page);
    		return false;
    	}else if(scroll_type==1){
    		question_replied(page);
    		return false;
    	}else if(scroll_type==2){
    		question_toEvaluate(page);
    		return false;
    	}else if(scroll_type==3){
    		question_complete(page);
    		return false;
    	}else if(scroll_type==4){
    		question_cancelled(page);
    		return false;
    	}
	    stopDefault(e);
	});
	
});
